<?php
require_once dirname(__FILE__) . '/../../../incls/php/dbutils.class.php';
require_once dirname(__FILE__) . '/../../../incls/php/miscutils.class.php';
require_once dirname(__FILE__) . '/../../../incls/php/config.php';
$myPdo = DbUtils::createPdoInst();
$page_id = MiscUtils::getParam('i', 0);

$SIZE = 12;
$page = MiscUtils::getParam('p', 1);
$order = MiscUtils::getParam('o', 't.date');
$queue = MiscUtils::getParam('q', 'DESC');
$cond_vals = new stdClass();
$cond_vals->c = 't.tag_ids LIKE :v1';
$cond_vals->v = array(':v1' => '%|' . NEWS_TAG_ID . '|%');
$items = DbUtils::get($myPdo,  TABLE_NAME_PREFIX_PLUGIN . 'art_post', $cond_vals, $order, $queue, $page, $SIZE, NULL)->d;
?>
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript" src="../../../libs/jquery/jquery-1.6.2.min.js"></script>
<style>
table.rightbar {
  width: 189px;
  border-left: 1px solid #aaa;
  border-top: 1px solid #aaa;
  margin-left: auto;
  text-align: left;
}
table.rightbar td {
  border-right: 1px solid #aaa;
  border-bottom: 1px solid #aaa;
  height: 25px;
  word-wrap: break-word;
  vertical-align: middle;
  overflow: hidden;
}
table.rightbar a.title {
  color: #000;
  font-size: 12px;
  font-family: Lucida Sans Unicode;
  margin-left: 5px;
}
table.rightbar td.date {
  color: #888;
  font-size: 11px;
  font-family: Verdana;
  width: 70px;
}
table.rightbar tr.title td {
  background:url(images/titlebg.gif) no-repeat;
  border-bottom: none;
  padding: 0 5px;
  padding-top: 3px;
  height: 25px;
  color: #fff;
  font-size: 14px;
  font-weight: bold;
  vertical-align: top;
  font-family: Lucida Sans Unicode;
}
table.rightbar tr.rowodd td {
  background-color: #fafafa;
}
table.rightbar tr.roweven td {
  background-color: #fff;
}
.linkbtn {
  border: none;
  background: #fff;
  padding: 0;
  text-decoration: underline;
  cursor: pointer;
  font-size: 11px !important;
  color: #666;
}
</style>
</head>

<body>
<div style="width: 100%; text-align: right;">
  <table class="rightbar" cellpadding=0 cellspacing=0>
    <tr class="title"><td colspan=2>Latest News</td></tr>
    <?php foreach ($items as $idx => &$item) { ?>
    <tr class="<?php echo ($idx % 2 == 0) ? 'roweven' : 'rowodd'; ?>"><td style="border-right: none;"><a class="title" href="#" onclick="parent.location.href='<?php echo 'http://' . URL . '?i=' . NEWS_ID . "&script=index_detail&art_id=$item->id&cat_id=" . TAG_NEWS_ID; ?>';"><?php echo MiscUtils::getShortName($item->title, 12); ?></a></td><td class="date"><?php echo $item->date; ?></td></tr>
    <?php } ?>
    <?php for ($i = count($items), $il = $SIZE; $i < $il; $i++) { ?>
    <tr class="<?php echo ($i % 2 == 0) ? 'roweven' : 'rowodd'; ?>"><td colspan=2>&nbsp;</td></tr>
    <?php } ?>
    <tr><td  colspan=2 style="text-align: right;"><a class="linkbtn" href="#" onclick="parent.location.href='<?php echo 'http://' . URL . '?i=' . NEWS_ID . '&cat_id=' . TAG_NEWS_ID; ?>';">Show all</a></td></tr>
  </table>
</div>

</body>
</html>
